<?php

namespace app\index\controller;

use app\common\model\PayLog;
use think\Controller;
use think\Request;

class Pay extends Controller
{
   public function notify_url(){
//       [ info ] [ PARAM ] array (
//           'app_time' => '1584615858',
//           'chart' => 'utf-8',
//           'id' => '12099',
//           'money' => '5',
//           'pay_id' => 'fc4069d49ea3d545408f3db18295bb1e',
//           'pay_no' => '2020031922001467871437599063',
//           'pay_time' => '1584615754',
//           'price' => '5',
//           'status' => '1',
//           'tag' => '0',
//           'trade_no' => '115846157301120996609648416',
//           'trueID' => '12099',
//           'type' => '1',
//           'version' => '6.530',
//           'sign' => '0c9b74efbbfd2faaf69e9da0c506f62a',
//       )
       $data = $this->request->param();
       $pay_order = PayLog::where('pay_order',$data['pay_id'])->find();
       if($pay_order['state'] == 0){
           //进行充值
           \app\common\model\User::where('Id',$pay_order['userid'])->setInc('balance',$pay_order['balance']);//充值积分
           PayLog::where('pay_order',$data['pay_id'])->setField('state',1);//完成状态
           return 'success';
       }

       return 'success';
   }
}
